<div class="contextual">
    <%= link_to_if_authorized l(:label_contact_new), {:controller => 'contacts', :action => 'new', :project_id => @project}, :class => 'icon icon-add' %>
</div>


<% html_title(@query.new_record? ? l(:label_contact_plural) : @query.name) %>


<%= form_tag({ :controller => 'contacts', :action => 'index', :project_id => @project }, :method => :get, :id => 'query_form') do %>
    <script type="text/javascript">
       jQuery(function($) {
          // when the #search field changes
          $("#search").observe_field(2, function() {
            var form = $("#query_form"); // grab the form wrapping the search bar.
            var url = form.attr("action");
            var formData = form.serialize();
            $.get(url, formData, function(data) { // perform an AJAX get, the trailing function is what happens on successful get.
                $("#contact_list").html(data); // replace the "results" div with the result of action taken
            });
          });
        });
    </script>

    <h2 class="contacts_header">
        <span id='scope_header' class="scope_title"> 
        <%= @query.new_record? ? l(:label_contact_plural) : h(@query.name) %>
        </span>

        <span class="live_search">  
            <%= text_field_tag(:search, params[:search], :autocomplete => "off", :class => "live_search_field", :placeholder => l(:label_contact_search) ) %>    

        </span>

        <span class="tags"> 
            <%= render(:partial => "tags_item", :collection => @filter_tags, :locals => {:is_note => true} ) %>
        </span> 

    </h2>

    <%= hidden_field_tag 'set_filter', '1' %>
    
<% end %>

<%= error_messages_for 'query' %>
<% if @query.valid? %>
    <div id="contact_list">  
    <% if @contacts.empty? %>
        <p class="nodata"><%= l(:label_no_data) %></p>
    <% else %>
      <%= render :partial => RedmineContacts.list_partial %>
    <% end %>
    </div>  
    <% other_formats_links do |f| %>
        <%= f.link_to 'Atom', :url => params.merge(:key => User.current.rss_key) %>
    <% end %>
<% end %>
   

<% html_title l(:label_contact_plural) %>  

<% content_for :sidebar do %>  
    <%= render :partial => 'common/sidebar' %>
    <%= render :partial => 'tags_cloud', :object => @tags %>
    <%= render :partial => 'notes/last_notes', :object => @last_notes %>        
    <%= render :partial => 'common/recently_viewed' %>    

    <%= call_hook(:view_contacts_sidebar_contacts_list_bottom) %>    

<% end %>

<% content_for(:header_tags) do %>
    <%= javascript_include_tag :contacts, :plugin => 'redmine_contacts'  %>
    <%= stylesheet_link_tag :contacts, :plugin => 'redmine_contacts' %>
    <%= stylesheet_link_tag :contacts_sidebar, :plugin => 'redmine_contacts' %>  
    <%= auto_discovery_link_tag(:atom, {:format => 'atom', :key => User.current.rss_key}, :title => l(:label_contact_plural)) %>
 
<% end %>     

<%= context_menu url_for( {:controller => "contacts", :action => "context_menu"} )%>  
